{% extends "upload/dataset_upload_metadata_base.html" %}
{% load i18n %}
{% load static %}
{% load pinax_ratings_tags %}
{% load bootstrap_tags %}
{% load pagination_tags %}
{% load base_tags %}
{% load guardian_tags %}
{% load client_lib_tags %}

{% block title %} {% trans "Upload Dataset Metadata"  %} - {{ block.super }}  {% endblock %}

{% block body_class %}layers upload{% endblock %}


{% block head %}

{{ block.super }}
{% endblock %}

{% block body_outer %}

<div class="page-header">
  <a href="{% dataset_list_url %}" class="btn btn-primary pull-right" style="margin-left: 3px;">{% trans "Explore Datasets" %}</a>
  <a href="{{ resource.get_absolute_url }}" class="btn btn-primary pull-right" style="margin-left: 3px;">{% trans "Return to Dataset" %}</a>
  <h2 class="page-title">{% trans "Upload Dataset Metadata" %} <small>{% trans "(XML - ISO, FGDC, ebRIM, Dublin Core)" %}<small></h2>
</div>

<div class="row">
  <div class="col-md-8">
    {% block additional_info %}{% endblock %}

    {% if errors %}
    <div id="errors" class="alert alert-danger">
      {% for error in errors %}
      <p>{{ error }}</p>
      {% endfor %}
    </div>
    {% endif %}

    <div id="upload-status"></div>

    <section id="drop-zone">
      <h3><i class="fa fa-cloud-upload"></i><br />{% trans "Drop files here" %}</h3>
    </section>

    <p>{% trans " or select them one by one:" %}</p>

    <form id="file-uploader" method="post" enctype="multipart/form-data">
      <!-- UI change to hide the list of previously uploaded files from the user -->
      <input type="file" id="file-input" style="display: none;" multiple>
      <input class="btn btn-default" type="button" value="{% trans "Choose Files" %}" onclick="document.getElementById('file-input').click();">
    </form>

    <section class="widget">
      <ul id="global-errors"></ul>
      <h4>{% trans "Files to be uploaded" %}</h4>
      <div id="file-queue"></div>
      <div class="checkbox" style="display:none;" id="metadata_upload_form_check">
          {% trans "Is Upload Metadata XML Form" %} <input type="checkbox" name="metadata_upload_form" id="id_metadata_upload_form" checked="true"/>
          <input type="text" name="dataset_title" id="id_dataset_title" value="{{ resource.alternate }}"/>
      </div>
    </section>

    <section>
      <a href="{% url "dataset_metadata_upload" resource.alternate %}" id="clear-button" class="btn btn-default">{% trans "Clear" %}</a>
      <a href="#" id="upload-button" class="btn btn-primary">{% trans "Upload files" %}</a>
    </section>
  </div>
</div>
{% endblock %}

{% block extra_script %}
    {{ block.super }}
    <script data-main="{% static 'geonode/js/upload/main.js' %}"
      src="{% static 'lib/js/require.js' %}">
    </script>
    <script type="text/javascript">
    {% autoescape off %}

      csrf_token =  "{{ csrf_token }}",
      form_target = "{{ LAYER_ANCILLARY_FILES_UPLOAD_URL }}",
      time_enabled = false,
      mosaic_enabled = false,
      userLookup = "{% url "account_ajax_lookup" %}"

    {% endautoescape %}

    </script>
{% endblock extra_script %}
